package com.bjpowerrnode.javase.array;
/*
动态初始化二维数组：

 */
public class ArrayTest12 {
    public static void main(String[] args) {

        //3行四列
        int[][] array = new int[3][4];

        /*
        //二维数组遍历
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.print("\n");
        }
         */

        //静态初始化
        int[][] a = {{1,2,3}, {4,4,4}, {5,5,6,6,7}};
        printArray(a);

        //没有这种语法
        //printArray({{1,2,3}, {4,4,4}, {5,5,6,6,7}});
        printArray(new int[][] {{1,2,3}, {4,4,4}, {5,5,6,6,7}});
    }

    public static void printArray(int[][] array){
        //二维数组遍历
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.print("\n");
        }
    }
}
